package top.hjcwzx.wrench.limiter.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import top.hjcwzx.wrench.limiter.memory.ExpirableKeyStore;

//memory内存配置
@ConfigurationProperties(prefix = "wrench-kit.limiter.memory", ignoreInvalidFields = true)
public class RateLimiterMemoryAutoProperties {

    /**
     * 内存淘汰策略(默认LRU:最早访问的淘汰,LFU:访问频率最少的淘汰)
     */
    ExpirableKeyStore.EvictionPolicy evictionPolicy = ExpirableKeyStore.EvictionPolicy.LRU;

    /**
     * key过期时间(10分钟,单位 毫秒 MILLISECONDS)
     */
    private Long expireAfterAccessMs = 10 * 60 * 1000L;

    /**
     * 最大缓存容量Key的个数
     */
    private Integer maxCacheSize = 10000;


    public ExpirableKeyStore.EvictionPolicy getEvictionPolicy() {
        return evictionPolicy;
    }

    public void setEvictionPolicy(ExpirableKeyStore.EvictionPolicy evictionPolicy) {
        this.evictionPolicy = evictionPolicy;
    }

    public Long getExpireAfterAccessMs() {
        return expireAfterAccessMs;
    }

    public void setExpireAfterAccessMs(Long expireAfterAccessMs) {
        this.expireAfterAccessMs = expireAfterAccessMs;
    }

    public Integer getMaxCacheSize() {
        return maxCacheSize;
    }

    public void setMaxCacheSize(Integer maxCacheSize) {
        this.maxCacheSize = maxCacheSize;
    }
}
